package com.soap.desensitize.strategy.irreversible;

import com.soap.desensitize.encry.irreversible.AbstractIRreversibleEncry;

/**
 * @desc：
 * @author： QGP
 * @create： 2022/4/27 20:26
 */
public class SubPhoneNumberStrtegy extends AbstractIRreversibleEncry {
    private static SubPhoneNumberStrtegy instance = null;
    private SubPhoneNumberStrtegy(){}

    /**
     * @desc 获得实例
     * @return
     */
    public static synchronized SubPhoneNumberStrtegy getInstance(){
        if(instance == null){
            instance = new SubPhoneNumberStrtegy();
        }
        return instance;
    }
    @Override
    public Object encode(Object data) {
        String phoneNumber = data.toString();
        boolean checkPhone = PhoneStrtegy.checkPhone(phoneNumber);
        String subPhoneNumber="";
        if (checkPhone){
            subPhoneNumber=phoneNumber.substring(phoneNumber.length()-4,phoneNumber.length());
        }
        return subPhoneNumber;
    }
}
